package com.example.DownloadImageHelper;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.ListView;
import com.example.DownloadImageHelperLibrary.NotifyAdapterDownloadImageTask;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by PNB on 3/28/14.
 */
public class NotifyAdapterActivity extends Activity {

    ListView listView1;
    ListView listView2;
    NotifyAdapter adapter;
    ArrayList<String> urlArrayList;
    File folder;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.notify_adapter_layout);

        folder = new File(Environment.getExternalStorageDirectory(),Environment.DIRECTORY_PICTURES);

        listView1 = (ListView)findViewById(R.id.listView1);
        listView2 = (ListView)findViewById(R.id.listView2);

        urlArrayList = new ArrayList<String>();
        urlArrayList.add("http://st.f1.vnecdn.net/i/v134/icons/logo_Vne03.png");
        urlArrayList.add("http://www.baomoi.com/App_Themes/Default/Images/baomoi_logo.gif");
        urlArrayList.add("http://tuoitre.vn/App_Themes/TuoiTre/images/logo.jpg");

        adapter = new NotifyAdapter(this,urlArrayList);
        listView1.setAdapter(adapter);
        listView2.setAdapter(adapter);

        for(String url : urlArrayList){
            int pos = url.lastIndexOf("/");
            String name = url.substring(pos+1);
            new NotifyAdapterDownloadImageTask(adapter,folder,name).execute(url);
        }
    }
}